package com.zt.controller;

import com.zt.service.FinancialProductService;
import com.zt.system.FinancialProduct;
import com.zt.utils.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("financialProduct")
public class FinancialProductController {
    @Resource
    private FinancialProductService financialProductService;
//    查询全部产品
    @GetMapping("/financialProductList")
    public Result getFinancialProductList(){
        return financialProductService.financialProductList();
    }
//    查询指定产品
    @GetMapping("/financialProductById")
    public Result financialProductById(@RequestParam("productId") Integer productId){
        return financialProductService.financialProductById(productId);
    }
//    查询商品单个数据
    @GetMapping("/getFinancialProductById")
    public FinancialProduct getFinancialProductById(@RequestParam("transactionId") Integer transactionId){
        return financialProductService.getFinancialProductById(transactionId);
    }
//    赎回
    @GetMapping("/financialProductByNumber")
    public Result financialProductByNumber(@RequestParam("number") Integer number,@RequestParam("productName") String productName){
        return financialProductService.financialProductByNumber(number,productName);
    }
//    购买
    @GetMapping("/getBoughtProduct")
    public Result getBoughtProduct(Integer number,String productName){
        return financialProductService.getBoughtProduct(number,productName);
    }
// 数量剪一
    @GetMapping("/updateNumber")
    public Result updateNumber(@RequestParam("productId") Integer productId,@RequestParam("number")Integer number){
        return financialProductService.updateNumber(productId,number);
    }
    // 数量加一
    @GetMapping("/addNumber")
    public Result addNumber(@RequestParam("productId") Integer productId,@RequestParam("number")Integer number){
        return financialProductService.addNumber(productId,number);
    }
}
